<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="Conexao.Conexao"%>
<%@page import="java.sql.Connection"%>
<%!
    public boolean verificarSenha(String email, String senha) {
        Connection con = null;
        Statement smt = null;
        ResultSet rs = null;
        boolean certo = false;
        try {
            con = Conexao.getConnection();
            smt = con.createStatement();
            rs = smt.executeQuery("select * from usuario where nm_email_usuario = '" + email + "' and cd_senha_usuario = " + senha);
            certo = rs.next();
        } catch (Exception e) {
        } finally {
            try {
                rs.close();
            } catch (Exception e) {
            }
            try {
                smt.close();
            } catch (Exception e) {
            }
            try {
                con.close();
            } catch (Exception e) {
            }
        }
        return certo;
    }

    public String verificarNome(String email) {
        Connection con = null;
        Statement smt = null;
        ResultSet rs = null;
        String nome = null;
        try {
            con = Conexao.getConnection();
            smt = con.createStatement();
            rs = smt.executeQuery("select nm_usuario, nm_sobrenome_usuario from usuario where nm_email_usuario = '" + email + "'");
            rs.next();
            nome = String.format("%s %s", rs.getString("nm_usuario"), rs.getString("nm_sobrenome_usuario"));
        } catch (Exception e) {
            nome = "???";
        } finally {
            try {
                rs.close();
            } catch (Exception e) {
            }
            try {
                smt.close();
            } catch (Exception e) {
            }
            try {
                con.close();
            } catch (Exception e) {
            }
        }
        return nome;
    }

    public int verificarPeso(String email) {
        Connection con = null;
        Statement smt = null;
        ResultSet rs = null;
        int peso = 0;
        try {
            con = Conexao.getConnection();
            smt = con.createStatement();
            rs = smt.executeQuery("select qt_peso_usuario from usuario where nm_email_usuario = '" + email + "'");
            rs.next();
            peso = Integer.parseInt(rs.getString("qt_peso_usuario"));
        } catch (Exception e) {
        } finally {
            try {
                rs.close();
            } catch (Exception e) {
            }
            try {
                smt.close();
            } catch (Exception e) {
            }
            try {
                con.close();
            } catch (Exception e) {
            }
        }
        return peso;
    }
    
    public int verificarCodigoAtividade(String email) {
        Connection con = null;
        Statement smt = null;
        ResultSet rs = null;
        int codigo = 0;
        try {
            con = Conexao.getConnection();
            smt = con.createStatement();
            rs = smt.executeQuery("select * from atividade where nm_email_usuario = '" + email + "'");
            while (rs.next()) {
                codigo++;
            }
        } catch (Exception e) {
        } finally {
            try {
                rs.close();
            } catch (Exception e) {
            }
            try {
                smt.close();
            } catch (Exception e) {
            }
            try {
                con.close();
            } catch (Exception e) {
            }
        }
        return codigo;
    }
%>
